<template>
	<view class="hui">

		<!-- <view class="tab_box">
			<u-search @search="getList" v-model="params.title" bg-color='white' :clearabled="true"  :show-action="false" placeholder="请输入您想要搜索的内容" ></u-search>
		</view> -->

		<view class="list_box">
			<view @click="to(item)" class="info" v-for="(item,index) in list" :key="index" >
				<image :src="item.image" class="img"></image>
				
				<view class="content_box">
					<view class="name">{{item.name}}</view>
					
					<view class="ibox">
						<u-icon name="clock" color="#92948B"></u-icon>
						<view class="time">{{item.timeText}}</view>
					</view>
					<view class="ibox">
						<u-icon name="map" color="#92948B"></u-icon>
						<view class="time">{{item.site}}</view>
					</view>
				</view>
				
				
				
			</view>
		</view>
		
		<view class="bitmap" v-if="emptyShow">
			<image :src="none" mode="aspectFit"></image>
			<view class="gray_font fs-13">
				暂无活动
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {	
				params: {
					page: 1,
					limit: 10,
					title:''
				},
				list: [],
				total: 0,
				emptyShow: false,
				none:''
			}
		},
		onShow() {
			this.$needLogin(()=>{
				this.getUserInfo();
			},3,'/pages/fw/event/index','请先登录',2);
		},
		onLoad(e) {
			this.none=this.$imgUrl+'assets/img/no_content.png';
			this.getList();
		},
		methods: {
			getUserInfo(){
				let token=uni.getStorageSync('userToken');
				if(!token) return;
				
				this.$get(this.$api.userInfo,{token:token},res=>{
					let data=res.data;
					if(data.code==1){
						this.user=data.data;
						this.$project.common(this.user,3,2);
					}
				});
				
			},
			to(e){
				this.$project.toPath('/pages/fw/event/info?id='+e.id);
			},
			getList() {
				this.params.page = 1;
				this.$get(this.$api.eventLists, this.params, res => {
					let data = res.data;

					if (!data.data.data || data.data.data.length < 1) {
						this.emptyShow = true;
					} else {
						this.emptyShow = false;
					}

					this.list = data.data.data;
					this.total = data.data.total;
				});
			},
			onReachBottom() {
				if (this.list.length < this.total) {
					this.params.page++;
					this.$get(this.$api.eventLists, this.params, res => {
						let data = res.data;
						data.data.data.forEach(ress => {
							this.list.push(ress);
						});
					});
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	
	.list_box{
		box-sizing: border-box;
		padding: 20rpx;
	}
	.info{
		box-sizing: border-box;
		padding: 10rpx;
		background-color: white;
		border-radius: 15rpx;
		margin-bottom: 20rpx;
	}
	.img{
		width: 100%;
		height: 350rpx;
		border-radius: 15rpx;
	}
	.content_box{
		box-sizing: border-box;
		padding: 10rpx 15rpx;
	}
	.name{
		font-weight: bold;
	}
	
	.ibox{
		display: flex;
		align-items: center;
		font-size: 26rpx;
		color: #92948B;
		margin-top:8rpx;
	}
	.time{
		margin-left: 15rpx;
	}
	.bitmap {
		margin-top: 10vh;
		text-align: center;
	}
	
	
	
	.f_s{
		display: flex;
		justify-content: space-between;
	}
	.f_c_s{
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
</style>